package fr.hoteia.appengine.archetype.server.model;

import java.io.Serializable;

import javax.persistence.Embeddable;

/**
 * <p>
 * <a href="Location.java.html"><i>View Source</i></a>
 * </p>
 *
 * @author Denis GOSSET <a href="http://www.hoteia.com"><i>Hoteia.com</i></a>
 * 
 */
@Embeddable
public class Location implements Serializable {

	/**
	 * Generated serial id
	 */
	private static final long serialVersionUID = -6325460767106163148L;

	protected String address;
	protected String cityName;
	protected String subCountryName;
	protected String countryCode;
	protected String postalCode;
	protected String encodedGMapLatLng;

	public Location() {
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public String geSubCountryName() {
		return subCountryName;
	}

	public void seSubCountryName(String subCountryName) {
		this.subCountryName = subCountryName;
	}
	
	public String getCountryCode() {
		return countryCode;
	}

	public void setCountryCode(String countryCode) {
		this.countryCode = countryCode;
	}

	public String getPostalCode() {
		return postalCode;
	}

	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}

	public String getEncodedGMapLatLng() {
		return encodedGMapLatLng;
	}

	public void setEncodedGMapLatLng(String encodedGMapLatLng) {
		this.encodedGMapLatLng = encodedGMapLatLng;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((address == null) ? 0 : address.hashCode());
		result = prime * result
				+ ((cityName == null) ? 0 : cityName.hashCode());
		result = prime * result
				+ ((countryCode == null) ? 0 : countryCode.hashCode());
		result = prime
				* result
				+ ((encodedGMapLatLng == null) ? 0 : encodedGMapLatLng
						.hashCode());
		result = prime * result
				+ ((postalCode == null) ? 0 : postalCode.hashCode());
		result = prime * result
				+ ((subCountryName == null) ? 0 : subCountryName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Location other = (Location) obj;
		if (address == null) {
			if (other.address != null)
				return false;
		} else if (!address.equals(other.address))
			return false;
		if (cityName == null) {
			if (other.cityName != null)
				return false;
		} else if (!cityName.equals(other.cityName))
			return false;
		if (countryCode == null) {
			if (other.countryCode != null)
				return false;
		} else if (!countryCode.equals(other.countryCode))
			return false;
		if (encodedGMapLatLng == null) {
			if (other.encodedGMapLatLng != null)
				return false;
		} else if (!encodedGMapLatLng.equals(other.encodedGMapLatLng))
			return false;
		if (postalCode == null) {
			if (other.postalCode != null)
				return false;
		} else if (!postalCode.equals(other.postalCode))
			return false;
		if (subCountryName == null) {
			if (other.subCountryName != null)
				return false;
		} else if (!subCountryName.equals(other.subCountryName))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Location [address=" + address + ", cityName=" + cityName
				+ ", subCountryName=" + subCountryName + ", countryCode="
				+ countryCode + ", postalCode=" + postalCode
				+ ", encodedGMapLatLng=" + encodedGMapLatLng + "]";
	}

}	